﻿function displayModalMessage(title, msg) {
    ExecuteOrDelayUntilScriptLoaded(internalDisplayModalMessage, "SP.JS");

    function internalDisplayModalMessage() {
        var htmlElement = document.createElement('div');
        htmlElement.setAttribute("style", "margin:10px");
        htmlElement.innerHTML = msg;

        var brElement = document.createElement('br');
        htmlElement.appendChild(brElement);
        var divElement = document.createElement('div');
        divElement.setAttribute("style", "margin-top:10px");
        divElement.setAttribute("text-align", "center");
        htmlElement.appendChild(divElement);
        var buttonElement = document.createElement('input');
        buttonElement.setAttribute("type", "button");
        buttonElement.setAttribute("value", "Close");
        buttonElement.setAttribute("class", "ms-ButtonHeightWidth");
        buttonElement.setAttribute("onclick", "javascript:SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, 'OK');");
        divElement.appendChild(buttonElement);

        var options = SP.UI.$create_DialogOptions();
        options.html = htmlElement;
        options.autoSize = true;
        options.allowMaximize = false;
        options.title = title;
        options.showClose = true;

        SP.UI.ModalDialog.showModalDialog(options);
    }
}

function displayModalUrl(title, url) {
    ExecuteOrDelayUntilScriptLoaded(internalDisplayModalUrl, "SP.JS");

    function internalDisplayModalUrl() {
        var options = SP.UI.$create_DialogOptions();
        options.url = url;
        options.autoSize = true;
        options.allowMaximize = false;
        options.title = title;
        options.showClose = true;

        SP.UI.ModalDialog.showModalDialog(options);
    }
}